﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Aulac.Global.Enums; using Aulac.Global.Data; using Aulac.Global.Common; using Aulac.Global.Xml;
using Aulac.Rsc.Ems; using Aulac.Rsc.Ems.Tags;
using System.Data;
using Aulac.Srv.Db.Provider; using Aulac.Srv.Db.Connect;
using Aulac.Srv.Db.Data.Catalogs;
using Aulac.Global.Exceptions;


namespace Aulac.Srv.Db.Data.Ems.Items.ItemType
{
    public class ClsCureStyles : DbDataCatalogs
    {
        private List<string> mList = new List<string>(new string[] { tagFnc.FncStyle.FncStyleID, tagFnc.FncStyle.FncStyleName, tagFnc.FncStyle.FncStyleTypeID });

        public ClsCureStyles(IDbAulacConnect pDb)
            : base(pDb, TableNames.Dm_CureStyles, tagFnc.FncStyle.FncStyleID,
            new string[] { tagFnc.FncStyle.FncStyleName, tagFnc.FncStyle.FncStyleTypeID }
            )
        {

        }
        protected override void OnGetListItem(ref DataTable pDataReturn, XmlDataDocument xmlParams)
        {
            try
            {
                string pCollection = XmlProcess.GetValueParam(xmlParams, tagItems.Common.CollectionFields);
                sqlQuery = string.Format("SELECT {0} FROM {1} ", StringHelper.ConvertArrayToString(", ", mList.ToArray()), mTableName);
                sqlQuery += string.Format(" WHERE (N'{0}' = '' OR {1} IN ({2}))", pCollection, tagFnc.FncStyle.FncStyleID, isEmpty(pCollection) ? "0" : pCollection);
                DbDataProvider.ExecuteReaderDataToTable(mDbCmd, sqlQuery, ref pDataReturn);
            }
            catch (Exception ex)
            {
                throw new AulacException(this, "OnGetListItem", ex.Message);
            }
        }
    }
}
